{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "violent-warning",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/find-smallest-letter-greater-than-target\n",
    "\n",
    "\n",
    "Runtime: 16 ms, faster than 79.53% of C++ online submissions for Find Smallest Letter Greater Than Target.\n",
    "Memory Usage: 15.8 MB, less than 92.81% of C++ online submissions for Find Smallest Letter Greater Than Target.\n",
    "\n",
    "\n",
    "```c++\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    char nextGreatestLetter(vector<char>& letters, char target) {\n",
    "        //7:36\n",
    "        vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};\n",
    "        int index;\n",
    "        for (int i=0; i<alphabet.size(); i++) {\n",
    "            if (target == alphabet[i]) {\n",
    "                index = i+1;\n",
    "                break;\n",
    "            }\n",
    "        }\n",
    "        for (auto c : letters) {\n",
    "            if (find(alphabet.begin()+index, alphabet.end(), c) != alphabet.end()) {\n",
    "                return c; \n",
    "            }\n",
    "        }\n",
    "        return letters[0];\n",
    "        //return 'yingshaoxo';\n",
    "        //7:43\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "animal-weather",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
